<template>
    <div
        style="padding-top: 40px"
        v-loading="pageLoading"
        element-loading-text="正在加载,请稍等"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
    >
        <div style="margin: 5px 10px 30px 15px">
            <el-row>
                <el-col :span="12">
                    <h3 class="small-title">认证信息</h3>
                </el-col>
            </el-row>

            <div style="margin: 5px 10px 30px 15px">
                <el-form
                    :model="dataForm"
                    :inline="true"
                    ref="ruleForm"
                    label-width="120px"
                    class="demo-ruleForm form-group"
                    label-position="top"
                >

                  <div v-if="userType==='企业'">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="法人名称" prop="ceoName">
                                <el-input type="text" v-model="dataForm.ceoName" placeholder="请输入法人名称" :disabled="isEdit"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="法人身份证" prop="ceoId">
                                <el-input type="text" v-model="dataForm.ceoId" placeholder="请输入法人身份证" :disabled="isEdit"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司名称" prop="fullName">
                                <el-input
                                    type="text"
                                    v-model="dataForm.fullName"
                                    placeholder="请输入公司名称"
                                    :disabled="isEdit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="单位类型" prop="corpType">
                                <el-select v-model="dataForm.corpType" placeholder="请选择" :disabled="isEdit">
                                    <el-option v-for="item in unitOptions" :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="企业注册类型" prop="corpRegisterType">
                                <el-select
                                    v-model="dataForm.corpRegisterType"
                                    placeholder="请选择"
                                    :disabled="isEdit"
                                    @change="selectCorpRegisterType(dataForm.corpRegisterType)"
                                >
                                    <el-option
                                        v-for="item in companyRegisterTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="labelCode" prop="certificateId">
                                <el-input type="text" v-model="dataForm.certificateId" placeholder="请输入" :disabled="isEdit"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="联系人姓名" prop="contactName">
                                <el-input
                                    type="text"
                                    v-model="dataForm.contactName"
                                    placeholder="请输入联系人姓名"
                                    :disabled="isEdit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="联系人身份证" prop="contactId">
                                <el-input
                                    type="text"
                                    v-model="dataForm.contactId"
                                    placeholder="请输入联系人身份证"
                                    :disabled="isEdit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>

                 </div>
                 <div v-else> 

                      <el-row>
                        <el-col :span="8">
                            <el-form-item label="姓名" prop="contactName">
                                <el-input
                                    type="text"
                                    v-model="dataForm.userId"
                                    placeholder=""
                                    :disabled="isEdit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="身份证" prop="contactId">
                                <el-input
                                    type="text"
                                    v-model="dataForm.cardId"
                                    placeholder=""
                                    :disabled="isEdit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>


                     </div> 
                </el-form>
            </div>
        </div>

        <span>
            <el-button style="margin: 20px 100px 100px 50px" autofocus type="primary" @click="closePage()">关闭页面</el-button>
        </span>
    </div>
</template>
<script>
import API from '@/api';
import cloneDeep from 'lodash/cloneDeep';

import { NZGMJL_RESULT_ITEMS, JDCZJL_RESULT_ITEMS, GMF_RESULT_ITEMS } from './config';

import { userType } from '../../utils/util';

export default {
    components: {},
    data() {
        return {
            pageLoading: false,
            isEdit: true,
            userType:'',
            dataForm: {
                ceoName: '', //法人名称
                ceoId: '', //法人身份证号
                certificateId: '', //营业执照代码(统一社会信用代码号)
                contactId: '', //联系人身份证号
                contactName: '', //联系人名称
                userName: '', // 公司名称
                corpType: '0', //单位类型
                corpRegisterType: 'NORMAL' //企业注册类型
            },

            unitOptions: [
                {
                    value: '0',
                    label: '普通企业'
                },
                {
                    value: '1',
                    label: '社会团体'
                },
                {
                    value: '2',
                    label: '事业单位'
                },
                {
                    value: '3',
                    label: '民办非企业单位'
                },
                {
                    value: '4',
                    label: '党政及国家机构'
                }
            ],
            labelCode: '组织机构代码号',
            companyRegisterTypeOptions: [
                {
                    value: 'NORMAL',
                    label: '组织机构代码号'
                },
                {
                    value: 'MERGE',
                    label: '多证合一'
                },
                {
                    value: 'REGCODE',
                    label: '企业工商注册码及其他'
                }
            ],

            //- 公用
            pageFlag: '',
            pageData: null
        };
    },
    mounted() {
        var itemData = this.$route.query.itemData;
        var type = this.$route.query.type;
      
        if (type == 2) {
            this.getPageDeail(itemData.userId); // 获取详情信息
            this.userType=userType(itemData.userType);//用户类型
            
        }

        this.dialogType = type;
    },

    methods: {
        handleClick(tab, event) {
            console.log(tab, event);
        },
        handleClose() {
            this.dataForm = {};
            this.$refs['dataForm'].resetFields();
        },
        // 获取页面详情
        getPageDeail(id) {
            //详情
            var _that = this;

            var tick;
            let params = {
                userId: id
            };

            _that.pageLoading = true;

            //详情
            API.realNameCertification.getDetails(params).then((res) => {
                console.log(res);

                _that.pageData = res.result;
                _that.dataForm = _that.pageData;

                //单位类型处理
                if (_that.pageData.corpType != null) {
                    _that.dataForm.corpType = _that.pageData.corpType + '';
                }
                _that.pageLoading = false;
            });
        },

        closePage() {
            this.$router.go(-1);
        }
    }
};
</script>
<style scoped>
</style>